package rules;

import java.util.HashSet;
import java.util.Set;

/**
 */
public abstract class RulesValidator<T> {

    private Set<Rule<T>> rules;

    public RulesValidator() {
        this.rules = new HashSet<Rule<T>>();
        this.addRules(this.rules);
    }

    public Set<Rule<T>> getRules() {
        return this.rules;
    }

    public void setRules(final Set<Rule<T>> rules) {
        this.rules = rules;
    }

    protected abstract void addRules(Set<Rule<T>> rules);

    public void validate(final T object) {
        for (Rule<T> r : this.rules) {
            r.validate(object);
        }
    }
}
